package com.shixun.dds_11.controller;


import com.shixun.dds_11.context.BaseContext;
import com.shixun.dds_11.dto.UserQueryDTO;
import com.shixun.dds_11.entity.DdsUser;
import com.shixun.dds_11.entity.User;
import com.shixun.dds_11.result.Result;
import com.shixun.dds_11.service.IUserService;
import com.shixun.dds_11.vo.UserQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YSP
 * @since 2024-07-05
 */
@RestController
@RequestMapping("/dds11/info")
@CrossOrigin
@Api(tags = "用户查询的相关接口")
@Slf4j
public class UserController {

    @Autowired
    private IUserService iuserService;

    /**
     * 根据id获取用户
     * @param
     * @return
     */
//    @GetMapping("query")
//    @ApiOperation(value = "根据id获取用户")
//    public Result<UserQueryVO> query(Long id) {
//        UserQueryVO userQueryVO = iuserService.getById(id);
//        return Result.success(userQueryVO);
//    }

    @GetMapping()
    @ApiOperation("查询用户信息")
    public Result<UserQueryVO> info(){
        log.info("查询用户信息");
        Integer userId = BaseContext.getCurrentId().intValue();
        log.info("{}", BaseContext.getCurrentId());
        return Result.success(iuserService.getByuserId(userId));

    }

}
